<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="countdown"></div>
    <script>
        const endTime = new Date('2024-08-15T23:59:59').getTime();
// 倒计时函数
function countdown() {
  const now = new Date().getTime();
  const distance = endTime - now;
  // 显示倒计时
  document.getElementById('countdown').innerText = `活动结束剩余时间：${distance / 1000} 秒`;
  // 检查倒计时是否结束
  if (distance < 0) {
    clearInterval(intervalId);
    document.getElementById('countdown').innerText = '活动已结束';
  }
}
// 设置定时器
const intervalId = setInterval(countdown, 1000);
    </script>
</body>
</html>